package com.neusoft.ysu.npms.controller;


import com.neusoft.ysu.npms.pojo.ApprovalInfo;
import com.neusoft.ysu.npms.pojo.Approval;
import com.neusoft.ysu.npms.pojo.Result;
import com.neusoft.ysu.npms.service.IApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者：刘金秋
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/approval")
public class ApprovalController {
    @Autowired
    IApprovalService approvalService;

    @RequestMapping("/add")
    public Result add(@RequestBody Approval approval) {
        approvalService.add(approval);
        return Result.success();
    }
    @RequestMapping("/delete")
    public Result deleteMeasure(@RequestBody Approval approval) {
        approvalService.deleteApproval(approval);
        return Result.success();
    }
    @RequestMapping("/update")
    public Result updateMeasure(@RequestBody Approval approval){
        approvalService.updateApproval(approval);
        return Result.success();
    }

    @RequestMapping("getAll")
    public Result getAll(){
        approvalService.selectAll();
        return Result.success();
    }

    @RequestMapping("findone")
    public Result findone(@RequestBody Approval approval){
        approvalService.findById(approval);
        return Result.success();
    }
    @RequestMapping("/applyvillage")
    public Result villagelist(@RequestBody ApprovalInfo approvalInfo,
                       @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                       @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize){
        return Result.success(approvalService.getvillagelist(approvalInfo, pageNum, pageSize));
    }
    @RequestMapping("/applytown")
    public Result townlist(@RequestBody ApprovalInfo approvalInfo,
                              @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                              @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize){
        return Result.success(approvalService.gettownlist(approvalInfo, pageNum, pageSize));
    }
    @RequestMapping("/applycounty")
    public Result countylist(@RequestBody ApprovalInfo approvalInfo,
                              @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                              @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize){
        return Result.success(approvalService.getcountylist(approvalInfo, pageNum, pageSize));
    }
    @RequestMapping("/applycity")
    public Result citylist(@RequestBody ApprovalInfo approvalInfo,
                              @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                              @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize){
        return Result.success(approvalService.getcitylist(approvalInfo, pageNum, pageSize));
    }
    @RequestMapping("/applyprovince")
    public Result provincelist(@RequestBody ApprovalInfo approvalInfo,
                              @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                              @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize){
        return Result.success(approvalService.getprovincelist(approvalInfo, pageNum, pageSize));
    }
    @RequestMapping("/applyback")
    public Result backlist(@RequestBody ApprovalInfo approvalInfo,
                              @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                              @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize){
        return Result.success(approvalService.getbacklist(approvalInfo, pageNum, pageSize));
    }
    @RequestMapping("/applysuccess")
    public Result applysuccess(@RequestBody ApprovalInfo approvalInfo){
        approvalService.applysuccess(approvalInfo);
        return Result.success();
    }
    @RequestMapping("/applyfail")
    public Result applyfail(@RequestBody ApprovalInfo approvalInfo){
        approvalService.applyfail(approvalInfo);
        return Result.success();
    }
    @RequestMapping("/logout")
    public Result logout(@RequestBody ApprovalInfo approvalInfo){
        approvalService.logout(approvalInfo);
        return Result.success();
    }

}